#include "MultNode.h"
#include <qobject.h>

MultNode::MultNode()
    :m_in1(new AbsIoNode(this, AbsIoNode::input))
    ,m_in2(new AbsIoNode(this, AbsIoNode::input))
    ,m_out(new AbsIoNode(this, AbsIoNode::output))
{
    registerIoNode("input", m_in1);
    registerIoNode("input2", m_in2);
    registerIoNode("output", m_out);
}

MultNode::~MultNode()
{
}

bool MultNode::run()
{
    qreal& in1 = (m_in1->variable());
    qreal& in2 = (m_in2->variable());
    qreal& out = (m_out->variable());
    out = in1 * in2;
    return true;
}

QString MultNode::lastErrorMsg()
{
    return QString();
}

QString MultNode::displayText()
{
    return nodeName();
}

QVariantMap MultNode::getParams()
{
    return QVariantMap();
}

void MultNode::setParams(QVariantMap paramsMap) { 
    Q_UNUSED(paramsMap)
}

inline void MultNode::initValue() 
{ 
    qreal& in1 = (m_in1->variable());
    qreal& in2 = (m_in2->variable());
    in1 = 1;
    in2 = 1;
}

QString MultNode::nodeName()
{
    return QObject::tr("Mult");
}
